package com.sinodata.atmp.components
{
    import mx.controls.Alert;

    public class IconAlert
    {
        [Embed(source="/skins/ErrorIcon.png")]
        public static var errorIcon:Class;
        
        [Embed(source="/skins/InfoIcon.png")]
        public static var infoIcon:Class; 
        
        [Embed(source="/skins/warnIcon.png")]
        public static var warnIcon:Class; 
        
        
        [Embed(source="/skins/quesIcon.png")]
        public static var quesIcon:Class;        
                   
        
        public static function showError(error:String,title:String="错误"):void{
            show(error,title,errorIcon);
        }
        
        public static function showInformation(error:String,title:String="提示"):void{
            show(error,title,infoIcon);
        }
        
        public static function showConformYN(error:String,title:String="确认",closeHandler:Function=null):void{
            initAlertButtonLabel();
            Alert.show(error,title,Alert.YES|Alert.NO,null,closeHandler,quesIcon,Alert.NO);
        }
        
        public static function showConformKC(error:String,title:String="确认",closeHandler:Function=null):void{
            initAlertButtonLabel();
            Alert.show(error,title,Alert.OK|Alert.CANCEL,null,closeHandler,quesIcon,Alert.CANCEL);
        }
       
        public static function showWarning(error:String,title:String="警告"):void{
            show(error,title,warnIcon);
        }
        
        private static function initAlertButtonLabel():void{
            Alert.okLabel = "确定";
            Alert.cancelLabel = "取消";
            Alert.yesLabel = "是";
            Alert.noLabel = "否";
        }        
        
        private static function show(error:String,title:String,icon:Class):void{
            
            initAlertButtonLabel();
            Alert.show(error,title,0,null,null,icon);
        }
    }
}